﻿using IVisual;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Runtime.Remoting.Channels;
using System.Runtime.Remoting.Channels.Tcp;
using System.Text;
using System.Threading.Tasks;

namespace Splitter_App
{
    class _cls_verbindung
    {
        private TcpClientChannel channel;
        public I_config _cfg;
        public I_Controller _ctrl;
        public IPAddress IP;
        public long Port;

        /// <summary>
        /// Handelt den Verbindungsaufbau
        /// </summary>
        /// <param name="IP">Ziel-IP</param>
        /// <param name="port">Ziel-Port</param>
        public void CONNECT_CONFIG()
        {
            channel = new TcpClientChannel();
            ChannelServices.RegisterChannel(channel, true);

            _cfg = (I_config)Activator.GetObject
            (
                typeof(I_config),
                "tcp://" + IP + ":" + Port + "/_RM_Neuro_Config"
            );
        }

        /// <summary>
        /// Stellt die Verbindung zu einer IP und Port her
        /// </summary>
        /// <param name="IP">Ziel-IP</param>
        /// <param name="port">Ziel-Port</param>
        public void CONNECT_CONTROLLER()
        {
            channel = new System.Runtime.Remoting.Channels.Tcp.TcpClientChannel();
            System.Runtime.Remoting.Channels.ChannelServices.RegisterChannel(channel, true);

            _ctrl = (I_Controller)Activator.GetObject
            (
                typeof(IVisual.I_Controller),
                "tcp://" + IP + ":" + Port + "/_RM_Neuro_Controller"
            );
        }
    }
}
